import 'dart:io';

import 'package:firstdemo/navigator/navigatorMain.dart';
import 'package:firstdemo/widget/WidgetMain.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';

import 'navigator/navigatorSecond.dart';
import 'ui/login.dart';

void main() {

  runApp(new MyApp());

  if (Platform.isAndroid) {
//    // 以下两行 设置android状态栏为透明的沉浸。写在组件渲染之后，是为了在渲染后进行set赋值，覆盖状态栏，写在渲染之前MaterialApp组件会覆盖掉这个值。
    SystemUiOverlayStyle systemUiOverlayStyle = SystemUiOverlayStyle(
      statusBarColor: Colors.transparent,
      statusBarBrightness: Brightness.light,
    );
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }

}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: "myApp",
      home: FirstPage(),
      routes: {
        '/navigatorSecond': (BuildContext context) =>
            navigatorSecond("Name push"),
        '/widgetMain': (BuildContext context) => WidgetMain(),
      },
    );
  }
}

class FirstPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return new Scaffold(
        appBar: new AppBar(title: new Text("Flutter"),brightness: Brightness.light,),
        body: Wrap(
          direction: Axis.vertical,
          children: <Widget>[
            RaisedButton(
                child: Text(
                  "导航和路由",
                  style: TextStyle(fontSize: 22),
                ),
                textTheme: ButtonTextTheme.accent,
                onPressed: () {
                  Navigator.push(
                      context,
                      new MaterialPageRoute(
                          builder: (context) => navigatorMain()));
                }),
            RaisedButton(
                child: Text(
                  "组件",
                  style: TextStyle(fontSize: 22),
                ),
                textTheme: ButtonTextTheme.accent,
                onPressed: () {
                  Navigator.push(
                      context,
                      new MaterialPageRoute(
                          builder: (context) => WidgetMain()));
                }),
            RaisedButton(
              focusColor: Colors.blueGrey,
              onPressed: () {
                Navigator.push(context,
                    new MaterialPageRoute(builder: (context) => Login()));
              },
              child: Text("蘑游库登录/注册"),
            )
          ],
        ));
  }
}
